﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;
using Data;


namespace Business
{
    public class Stats
    {
        private DataStats datalayer;

        public Stats()
        {
            this.datalayer = new DataStats();
        }

        public List<Auxiliar> getNrCommentsUser()
        {
            List<Auxiliar> sl = this.datalayer.getNrCommentsUser();
            List<Auxiliar> aux = new List<Auxiliar>();
            Auxiliar a = new Auxiliar();
            int max = -1;
            int key = -1;
            int maxi = -1;
            int val = sl.Count;
            


            for (int j = 0; j < val; j++)
            {
                max = -1;
                key = -1;
                maxi = -1;
                a = new Auxiliar();
                for (int i = 0; i < sl.Count;i++ )
                {
                    if (sl[i].getNrComments() > max)
                    {
                        max = sl[i].getNrComments();
                        key = sl[i].getUserID();
                        maxi = i;
                    }
                }
                sl.RemoveAt(maxi);
                a.setUserId(key);
                a.setNrComments(max);
                aux.Add(a);
            }

            return aux;
        }
    }

    
}
